﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.MobileControls;
using System.Collections;

public partial class SelectionList_DataboundListExample : System.Web.UI.MobileControls.MobilePage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        this.Command1.Click += new System.EventHandler(this.HandleMultiTeamSelection);
        if (!IsPostBack)
        {
            ArrayList array = new ArrayList();
            array.Add(new TeamStats("Dunes", "Posn:1 Pl:38 Pts:80"));
            array.Add(new TeamStats("Phoenix", "Posn:2 Pl:38 Pts:70"));
            array.Add(new TeamStats("Eagles", "Posn:3 Pl:38 Pts:69"));
            array.Add(new TeamStats("Zodiac", "Posn:4 Pl:38 Pts:68"));
            SelectionList1.DataSource = array;
            SelectionList1.DataBind();
        }
    }
    private void HandleMultiTeamSelection(Object source, EventArgs args)
    {
        this.ActiveForm = Form2;

        // Get the list items collection.
        MobileListItemCollection colItems = SelectionList1.Items;
        String strDisplaytext = "";
        foreach (MobileListItem item in colItems)
        {
            if (item.Selected)
            {
                strDisplaytext += (item.Text + ": " + item.Value +
                "<br/>");
            }
        }
        TextView1.Text = strDisplaytext;
    }
}